Managing the Knowledge Base Widget
  • 16 May 2024
  • 4 Minutes to read
  • Contributors
  • Dark
    Light

Managing the Knowledge Base Widget

  • Dark
    Light

Article summary

You can easily manage your Knowledge base widget in Document360. All options are available just a few clicks away.
12_Screenshot-Knowledge_base_widget-Managing_widget


Securing Knowledge base widget authentication using JWT

You can implement an authentication configuration for the widget using JWT, ensuring a secure environment for private and mixed projects.

       
  1.        

    In your , go to the Knowledge base widget. The list of widgets will be listed

       
  2.    
  3.        

    Hover over the desired widget and click Edit (✎)

       
  4.    
  5.        

    In Installation & setupJWT, enable the JWT toggle

       
14_Sceenshot-NEW_JWT_for_Knowledge_base_widget_authentication
       
  1.        

    Client ID: The client ID will be your project’s ID

       
  2.    
  3.        

    Widget ID: Since multiple widgets may exist, Widget ID is provided for their unique purposes.

       
  4.    
  5.        

    Token endpoint: A token endpoint is an HTTP endpoint that allows you to obtain an access token given an authorization code

       
  6.    
  7.        

    Client secret: Click Regenerate to generate the client secret. You have to save this for future purposes and the same client secret will apply to all the widgets in the future

       
   
       

   
   
       

Client secret will be required for JWT widgets you may create. Note that this information will not be stored in Document360.

   
       
  1.        

    Authorize URL: Paste the authorized URL from your knowledge base widget webpage

       
  2.    
  3.        

    Once done, click Save.

       

The same authorized URL will be embedded inside the code. Copy and paste the code into your script selection on your webpage.

An authenticated widget will be successfully implemented, which is secured so that a third-party person can’t access the widgets.

How to implement the auth endpoint?

[HttpGet]
[Route("authenticate")]
public async Task<IActionResult> WidgetAuthentication(string id)
{
    if (HttpContext.User.Identity.IsAuthenticated)
    {
        var clientData = new ClientDetails()
        {
            ClientId = "{Client ID}",
            Secret = "{Client secret}",
            TokenEndpoint = "{Token endpoint}",
            WidgetId = "{Widget ID}",
            SecurityGroupIds = "{Comma separated reader group IDs}",
            TokenValidity = 15, // integer representing token validity in minutes
        };

        if (clientData == null)
            return NotFound();

        List<string> readerGroupids = null;
        if (!string.IsNullOrEmpty(clientData.SecurityGroupIds))
            readerGroupids = clientData.SecurityGroupIds.Split(',').Select(c => c.Trim()).ToList();

        var payload = new
        {
            username = "{Username}",
            firstName = "{First name}",
            lastName = "{Last name}",
            emailId = "{Email address}",
            readerGroupIds = readerGroupids,
            tokenValidity = clientData.TokenValidity,
            widgetId = clientData.WidgetId,
            projectId = clientData.ClientId
        };

        var payloadString = JsonConvert.SerializeObject(payload);

        var result = await client.RequestTokenAsync(new TokenRequest
        {
            Address = clientData.TokenEndpoint,
            ClientId = clientData.ClientId,
            ClientSecret = clientData.Secret,
            GrantType = "Widget",
            Parameters =
            {
                {
                    "payload",  payloadString
                },
                {
                    "id", clientData.ClientId
                },
            }
        });

        return Ok(new
        {
            accessToken = result.AccessToken,
            expiresIn = result.ExpiresIn
        });
    }
    else
    {
        return Unauthorized(new { success = false });
    }
}

Edit Knowledge base widget

14_Screenshot-Knowledge_base_widget-Managing_widget_Edit_script
       
  1.        

    Go to Settings → Knowledge base widget

       
  2.    
  3.        

    Hover over the desired Knowledge base widget and click Edit

       
  4.    
  5.        

    Update the desired configurations

       
  6.    
  7.        

    Click Save

       

Clone Knowledge base widget

15_Screenshot-Knowledge_base_widget-Managing_widget_Clone_script
       
  1.        

    Go to Settings → Knowledge base widget

       
  2.    
  3.        

    Hover over the desired Knowledge base widget from which you want to clone and click Clone

       
  4.    
  5.        

    Type a title and click Create

       
  6.    
  7.        

    Update the desired configurations

       
  8.    
  9.        

    Click Save

       

Delete Knowledge base widget

16_Screenshot-Knowledge_base_widget-Managing_widget_Delete_script
       
  1.        

    Go to Settings → Knowledge base widget

       
  2.    
  3.        

    Hover over the desired Knowledge base widget you want to delete and click Delete

       
  4.    
  5.        

    Click Yes in the confirmation prompt

       

Copy script of Knowledge base widget

13_Screenshot-Knowledge_base_widget-Managing_widget_Copy_script
       
  1.        

    Go to Settings → Knowledge base widget

       
  2.    
  3.        

    Hover over the desired Knowledge base widget you want to delete and click Copy script

       
  4.    
  5.        

    Paste the copied script in your website or Knowledge base HTML section to insert the Knowledge base widget

       


Was this article helpful?

ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence